<?php
class ControleChaPanela extends Control
{
	public function index()
	{
		$this->setLayout('casamento');

		$item = new Item();
		$items = $item->search(null, array('id_lista' => ' = 1'));

		$this->view->assign('items', $items);
		return $this->view;
	}

	public function informacoes()
	{
		return $this->view;
	}

	public function verItem()
	{
		$this->setTemplate('presentear');

		try {
			$id = $this->params['id_item'];
			$item = new Item();
			$item->load($id);

			$this->view->assign('item', $item);
			echo $this->view->fetch('php:presentear.php');

		} catch (Exception $e) {
			echo $e->getMessage();
		}
	}

	public function presentear()
	{
		$id = $this->params['id_item'];
		$item = new Item();
		$item->load($id);

		$item->usuario = $this->params['nome'];
		$item->status = 1;
		$item->save();

		$output = array('id' => $item->id);
		echo json_encode($output);
	}
}